package com.cindata

import com.cindata.dictionary.CollateralStage
import com.cindata.dictionary.RiskWarningStage
import com.cindata.dictionary.AbnormalMortgageBatchStage
import com.cindata.dictionary.AccountStage

class Comment
{
    CollateralStage stage
    RiskWarningStage warningStage
    AbnormalMortgageBatchStage abnormalMortgageBatchStage
    AccountStage accountStage
    String comment
    User user

    Date createdDate = new Date()
    Date modifiedDate = new Date()

    static belongsTo = [collateral: Collateral, riskWarning: RiskWarning, abnormalMortgageBatch: AbnormalMortgageBatch, account: Account]

    static constraints = {
        comment type: "text"
        stage nullable: true, blank: true
        warningStage nullable: true, blank: true
        abnormalMortgageBatchStage nullable: true, blank: true
        accountStage nullable: true, blank: true
        user nullable: true, blank: true
        collateral nullable: true, blank: true
        riskWarning nullable: true, blank: true
        abnormalMortgageBatch nullable: true, blank: true
        account nullable: true, blank: true
    }

    def springSecurityService

    def beforeInsert()
    {
        user = User.findByUsername(springSecurityService?.getPrincipal()?.username)
    }

    def beforeUpdate()
    {
        modifiedDate = new Date()
    }
}
